﻿Imports System.Data.OleDb

Public Class Profile
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.Params("FoodUser") = User.Identity.Name Then
            btn_EditProfile.Visible = True
            ph_Rating.Visible = False
        Else
            btn_EditProfile.Visible = False
            ph_Rating.Visible = True
        End If


    End Sub

    Protected Sub btn_SaveRating_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_SaveRating.Click

        Dim oleDbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("FoodConnectionString").ConnectionString)
        oleDbConn.Open()

        Dim addRatingSql As String = "Insert into UserRatings(FoodUser,Rating) Values (@f1,@f2)"
        Dim addRatingCmd As New OleDbCommand(addRatingSql, oleDbConn)
        addRatingCmd.Parameters.AddWithValue("@f1", Request.Params("FoodUser"))
        addRatingCmd.Parameters.AddWithValue("@f2", Rating1.CurrentRating)
        addRatingCmd.ExecuteNonQuery()

        Label1.Text = "Thank you for adding your rating!"

    End Sub

End Class